-- plugins/project.lua
return {
	"ahmedkhalf/project.nvim",
	lazy = false,

	keys = {
		{ "<leader>fp", "<cmd>Telescope projects<cr>", desc = "Find Projects" },
	},

	config = function()
		require("project_nvim").setup({
            manual_mode = false, -- Only change cwd on explicit :Telescope projects
			detection_methods = { "pattern" },
			-- patterns = { ".git", "Makefile", "compile_commands.json" },
			patterns = { ".project", "compile_commands.json" },
			silent_chdir = false,

			-- 每次切换 project 之后，重新启动 LSP
			on_project_changed = function(project_path)
				-- 清除当前会话
				require("auto-session").clear_session()
				vim.cmd("LspStop")
				vim.cmd("LspStart")
				print("Project changed to: " .. project_path)
			end,
		})

		require("telescope").load_extension("projects")
	end,
}
